#include "stdafx.h"
#include "player.h"
#include "common.h"

void pLayer( const unsigned char in_player[] , unsigned char out_player[] )
{
	int sbox_count[8][8] ;
	const unsigned int p[block_bits] = {
		0 , 16 , 32 , 48 , 1 , 17 , 33 , 49 , 2 , 18 , 34 , 50 , 3 , 19 , 35 , 51 , 
		4 , 20 , 36 , 52 , 5 , 21 , 37 , 53 , 6 , 22 , 38 , 54 , 7 , 23 , 39 , 55 , 
		8 , 24 , 40 , 56 , 9 , 25 , 41 , 57 , 10 , 26 , 42 , 58 , 11 , 27 , 43 , 59 , 
		12 , 28 , 44 , 60 , 13 , 29 , 45 , 61 , 14 , 30 , 46 , 62 , 15 , 31 , 47 , 63 
	} ;
	unsigned char tmp[block_bits];
	for ( int i = 0 ; i < block_bits ; i++ )
	{
		tmp[p[i]] = in_player[i] ;
	}
	memcpy(out_player, tmp, block_bits);

// 	for ( int row = 0 ; row <= 7 ; row++ )
// 	{
// 		for ( int col = 0 ; col <= 7 ; col++ )
// 		{
// 			sbox_count[row][col] =(p[8*row+col]/4) ;
// 			printf( "%d " , sbox_count[row][col] ) ;
// 		}
// 		printf( "\n" ) ;
// 	}
}